<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no" />
    <title>title</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css"/>
    <style>
        html,body{
            height: 100%;
            background: #f8f8f8;
        }
        input {
            outline: none;
        }
        #inp {
            width: 90%;
            margin:10px auto;
            display: block;
            background: #fff;
            height: 40px;
            line-height: 40px;
            border-radius: 5px;
            padding-left: 5px;
        }
    </style>
</head>
<body>
    <input id="inp" type="text" placeholder="" value="">
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/zepto.js"></script>
<script type="text/javascript" src="../script/common.js"></script>
<script type="text/javascript">
    apiready = function(){
        var field = api.pageParam.field;
        var name = api.pageParam.name;
        var holder = api.pageParam.holder;
        var type = api.pageParam.type;
        var old_value = api.pageParam.value;
        $('#inp').attr('type',type);
        $('#inp').attr('placeholder',holder);
        $('#inp').val(old_value);
        api.addEventListener({
            name: 'confirmEditGoodsEvent'
        }, function(ret, err) {
            if (ret) {
                var value = $('#inp').val();
                if(!value) {
                    api.toast({
                        msg: '请先填入'+name,
                        location:'middle'
                    });
                    return;
                }
                if(field == 'phone') {
                    if(isMobile(value) == 0) {
                        api.toast({
                            msg: '手机号码格式错误',
                            location: 'middle'
                        });
                        return;
                    }
                }
                api.sendEvent({
                    name: 'editShopInfoEvent',
                    extra: {
                        edit: field, 
                        value: value,
                        desc: value
                    }
                });
                api.closeWin();
            }
        });

    };
</script>
</html>